package com.fancyy.scm.util;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.fancyy.scm.BRApplication;

/**
 * Created by curry on 2017/8/10.
 */

public class ManagerUtil {
    /**
     * 获取版本号，版本名称
     *
     * @return
     */
    public static String getPackageVersionInfo() {
        //获得包名
        Context context = BRApplication.getInstance();
        String packageName = context.getPackageName();
        PackageManager packageManager = context.getPackageManager();
        try {
            PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
            String versionName = packageInfo.versionName;
            int versionCode = packageInfo.versionCode;
            return /*context.getString(R.string.version_name) + */versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return "";
    }

}
